<template>
  <div class="app-container">
    <el-card shadow="never">
      <el-form :inline="true" :model="searchForm" class="search-form">
        <el-form-item label="护士姓名">
          <el-input v-model="searchForm.nurseName" clearable>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleFilter" class="search-button">查询</el-button>
          <el-button @click="handleReset" class="search-button">重置</el-button>
          <!-- <el-button type="primary" @click="verify">确认</el-button> -->
          <el-button type="primary" @click="close">返回</el-button>
        </el-form-item>
      </el-form>

      <el-table ref="table" v-loading="listLoading" :data="list" element-loading-text="Loading" fit highlight-current-row>
        <!-- <el-table-column align="center" type="selection" label="序号" width="55">
        </el-table-column> -->
        <el-table-column align="center" type="index" label="序号" width="55">
        </el-table-column>
        <el-table-column label="护士姓名" align="center" prop="nurseName">
        </el-table-column>
        <el-table-column label="身份证号" align="center" prop="idNum">
        </el-table-column>
        <el-table-column label="所属区域" align="center" prop="region">
        </el-table-column>
        <el-table-column label="职称" align="center" prop="positionalTitles">
        </el-table-column>
        <el-table-column label="所属医院" align="center" prop="hospitalName">
        </el-table-column>
        <el-table-column label="性别" align="center" prop="sex">
        </el-table-column>
        <el-table-column label="手机号" align="center" prop="tel">
        </el-table-column>
        <el-table-column label="图像" align="center" prop="pictureName">
          <template slot-scope="{row}">
            <el-image style="width: 100px; height: 100px" :src="row.pictureName" :preview-src-list="[row.pictureName]">
            </el-image>
          </template>
        </el-table-column>
        <el-table-column label="行医时间" align="center" prop="practiseMedicineTime">
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime">
        </el-table-column>
        <el-table-column align="center" label="操作" width="200">
          <template slot-scope="{row}">
            <el-button @click="select(row)" type="text">选中</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageIndex" :limit.sync="searchForm.pageSize"
        @pagination="getList" />
    </el-card>
  </div>
</template>

<script>
import * as NurseManagement from '@/api/NurseManagement'
import Pagination from '@/components/Pagination'
export default {
  components: { Pagination },
  props: {
    evaluationType: {
      type: String
    }
  },
  data () {
    return {
      list: null,
      listLoading: true,
      searchForm: {
        pageIndex: 1,
        pageSize: 10
      },
      total: 0,
    }
  },
  created () {
    this.getList()
  },
  methods: {
    getList () {
      this.listLoading = true
      let param = Object.assign({}, this.searchForm)
      param.hospitalUid = localStorage.getItem('hospitalUid')
      NurseManagement.queryByPage(param).then(response => {
        this.list = response.data.rows
        this.total = response.data.total
        this.listLoading = false
      }).catch(error => {
        this.listLoading = false
        console.log(error)
      })
    },
    handleFilter () {
      this.searchForm.pageIndex = 1
      this.getList()
    },
    handleReset () {
      this.resetTemp();
      this.getList();
    },
    resetTemp () {
      this.searchForm = {
        pageIndex: 1,
        pageSize: 10
      }
    },
    verify () {
      let arr = this.$refs.table.selection
      if (arr.length === 0) {
        this.$message.error('请勾选数据！')
      } else {
        this.$emit('close', arr)
      }
    },
    close () {
      this.$emit('close', '')
    },
    select (row) {
      this.$emit('close', row)
    }
  }
}
</script>
